package com.sskj.gocoin;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.flyco.dialog.utils.CornerUtils;
import com.flyco.dialog.widget.base.BaseDialog;
import com.sskj.lib.RConfig;

public class ComDialog extends BaseDialog<ComDialog> {
    private TextView cancelTv;
    private TextView confirmTv;
    private TextView msgTv;
    private OnComBtnClickListener onComBtnClickListener;
    private String confrimText = "";
    private String cancelText = "";
    private String msg = "";
    public ComDialog(Context context,String confirmText,String cancelText,String msg,OnComBtnClickListener onComBtnClickListener) {
        super(context);
        this.onComBtnClickListener = onComBtnClickListener;
        this.confrimText = confirmText;
        this.cancelText = cancelText;
        this.msg = msg;
    }

    @Override
    public View onCreateView() {
        widthScale(0.7f);
        View conView = LayoutInflater.from(mContext).inflate(R.layout.dialog_com,null);
        cancelTv = conView.findViewById(R.id.tv_dialog_com_cancel);
        confirmTv = conView.findViewById(R.id.tv_dialog_com_confirm);
        msgTv = conView.findViewById(R.id.tv_dialog_com_msg);
//        conView.setBackgroundDrawable(CornerUtils.cornerDrawable(Color.WHITE, dp2px(0f)));
        conView.setBackground(CornerUtils.cornerDrawable(mContext.getResources().getColor(R.color.tabNormalColor),dp2px(5f)));
        return conView;
    }

    @Override
    public void setUiBeforShow() {
        cancelTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(onComBtnClickListener!=null){
                    onComBtnClickListener.onCancel();
                }
                dismiss();
            }
        });
        confirmTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(onComBtnClickListener!=null){
                    onComBtnClickListener.onConfirm();
                }
                dismiss();
            }
        });

        confirmTv.setText(confrimText);
        cancelTv.setText(cancelText);
        msgTv.setText(msg);
    }

    public interface OnComBtnClickListener{
        void onConfirm();
        void onCancel();
    }
}
